﻿using DevExpress.Web.ASPxScheduler;
using DevExpress.Web.ASPxScheduler.Internal;
using DevExpress.XtraScheduler;

public class ScheduleAppointmentFormController : AppointmentFormController 
{
	public ScheduleAppointmentFormController(ASPxScheduler control, Appointment appointment)
		: base(control, appointment) {
	}
	public int? ContactId { get { return (int?)EditedAppointmentCopy.CustomFields["ContactId"]; } set { EditedAppointmentCopy.CustomFields["ContactId"] = value; } }
	public int? ClientId { get { return (int?)EditedAppointmentCopy.CustomFields["ClientId"]; } set { EditedAppointmentCopy.CustomFields["ClientId"] = value; } }

	int? SourceContactId { get { return (int?)SourceAppointment.CustomFields["ContactId"]; } set { SourceAppointment.CustomFields["ContactId"] = value; } }
	int? SourceClientId { get { return (int?)SourceAppointment.CustomFields["ClientId"]; } set { SourceAppointment.CustomFields["ClientId"] = value; } }

	public override bool IsAppointmentChanged() {
		if (base.IsAppointmentChanged())
			return true;
		return SourceContactId != ContactId || SourceClientId != ClientId;
	}
	protected override void ApplyCustomFieldsValues() {
		SourceContactId = ContactId;
		SourceClientId = ClientId;
	}
}
